package com.deli.controller;

import com.deli.anno.DeliAutoWried;
import com.deli.anno.DeliController;
import com.deli.anno.DeliRequestMapping;
import com.deli.anno.DeliRequestParam;
import com.deli.service.TestService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Description:
 * @Author: xudeli
 * @CreateDate: 2019/8/24 22:00
 **/
@DeliController
@DeliRequestMapping("/aaa")
public class TestController {

    @DeliAutoWried("TestServiceImpl")
    private TestService testService;

    @DeliRequestMapping("/query")
    public void TestSpringMvc(HttpServletRequest request, HttpServletResponse response,@DeliRequestParam(value = "name") String name) {

        try {
            System.out.println("testSpringmvc mothod input param :name=" + name);
            String res = testService.testSpringmvc(name);
            System.out.println("res=" + res);
            response.setHeader("Content-Type","text/html;charset=UTF-8");
            response.setCharacterEncoding("UTF-8");
            PrintWriter writer = response.getWriter();
            writer.write(res);
            response.getWriter().flush();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
